package aleetcode;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Solution {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        System.out.println("请输入一个数组长度:");
        int n=scan.nextInt();
        int []arr=new int[n];
        for(int i=0;i<n;i++){
            System.out.println("请输入第"+(i+1)+"个数:");
            arr[i]=scan.nextInt();
        }
        System.out.println(Arrays.toString(arr));
        int[] ints = removeDuplicates(arr);
        System.out.println(Arrays.toString(ints));
    }
    public static int[] removeDuplicates(int[] nums) {
        List<Integer>list =new LinkedList<>();
        for(int num:nums){
            if(!list.contains(num)){
                list.add(num);
            }
        }
        return list.stream().mapToInt((Integer num) -> num.intValue()).toArray();
    }
}





